package com.example.mongodb_demo.service.impl;

import com.example.mongodb_demo.doman.Category;
import com.example.mongodb_demo.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public Category save(Category category) {
        return mongoTemplate.save(category);
    }

    @Override
    public List<Category> findAll() {
        return mongoTemplate.findAll(Category.class);
    }
}
